﻿<div class="datagrid-toolbar formToolBar">
    <a href="#" class="easyui-linkbutton" plain="true" onclick="save()" iconcls="iconfont iconfont-baocun">保存</a>
</div>
<div style="padding:2px;">    
    <form method="post">
        <input id="Id" name="Id" type="hidden" />
        <table class="groupTable">
            <tr>
                <td style="width:15%">
                    编号:
                </td>
                <td style="width:35%">
                    <input id="Code" name="Code" class="easyui-textbox" style="width: 100%" data-options="required:true" />
                </td>
                <td style="width:15%">名称:</td>
                <td style="width:35%">
                    <input id="Name" name="Name" class="easyui-textbox" style="width: 100%" data-options="required:true" />
                </td>
            </tr>
            <tr>
                <td>备注:</td>
                <td colspan="3">
                    <input id="Remark" name="Remark" class="easyui-textbox" data-options="multiline:true" value="" style="width: 100%; height: 180px">
                </td>
            </tr>
        </table>
    </form>
</div>
<script>
    var formData = {};
</script>
<script>
    var id = queryString('id');
    var roleType = queryString('RoleType');

    function pageLoad() {
        //编辑
        if (id) {
            $("#Id").val(id);
            addAjaxParam("id", id);
            commitAjax("GetRole", {
                CallBack: function (data) {
                    if (data) {
                        formData = data;
                        $('#Code').textbox('setValue', data.Code);
                        $('#Name').textbox('setValue', data.Name);
                        $('#Remark').textbox('setValue', data.Remark);
                    }
                }
            });
        }
    }

    function save() {
        var isValid = $('form').form('validate');
        if (!isValid) {
            msgBox('请检查所填数据!');
            return;
        }

        var t = $('form').serializeArray();
        $.each(t, function () {
            formData[this.name] = this.value;
        });
        addAjaxParam("formData", formData);
        addAjaxParam("roleType", roleType);
        commitAjax("SaveRole", {
            CallBack: function (data) {
                if (data) {
                    closeWindow(formData);
                }
                else {
                    msgBox('操作失败');
                }
            }
        })
    }
</script>
